'use strict'

const fs = require('fs');
const path = require("path");

let fixJsPath = process.argv[2];
console.log("fixJsPath =====", fixJsPath);
// fixJsPath = path.resolve() + "/" + fixJsPath
// console.log("fixJsPath =2====", fixJsPath);
let channelId = process.argv[3];
console.log("channelId =====", channelId);

fs.readFile(fixJsPath, (err, buf) => {
    if (err) {
        console.warn("fixchannelid error readFile==", fixJsPath);
    } else {
        let str = "window.defaultChannelId = " + channelId + ";"
        let newBuf = Buffer.from(str);
        fs.writeFile(fixJsPath, newBuf, function(err) {
            if (err) {
                console.warn("fixchannelid error writeFile==", fixFile);
            }
        });
    }
});